package Work;

/*计算坐标中两点之间的距离*/
class Point {
    private double x1;
    private double y1;
    private double x2;
    private double y2;

    Point(double x1,double y1,double x2,double y2) {
        this.x1 = x1;
        this.y1 = y1;
        this.x2 = x2;
        this.y2 = y2;
    }

    public double distance() {
        double num1 = Math.pow((this.x1 - this.x2),2);
        double num2 = Math.pow((this.y1 - this.y2),2); // pow 求平方
        return Math.sqrt(num1+num2); // sqrt 求平方根
    }

}

public class work {
    public static void main(String[] args) {
        Point point = new Point(3,4,0,0); // 调用构造方法
        System.out.println("这两点之间的距离为:"+point.distance());
    }

}
